<style type="text/css" scoped="scoped">
    .roleName {
        cursor: pointer;
        line-height: 20px;
    }
</style>
<div class="userRoleSetTree">
<#list roles as m>
    <div id="${m._id}" pid="${m.parentId}">
            <span class="roleName" title="${m.notes!""}" onclick="saveRole('${m._id}','${m.name}')">
            <span class="icon-user2"></span>
            <span class="name">${m.name}</span>
            </span>
    </div>
</#list>
</div>
<script type="text/javascript">
    var userRoleSetTree = $('.userRoleSetTree').jTree();
    userRoleSetTree.showAll();
    function saveRole(value, roleName) {
        if (!confirm('确定更改角色为：' + roleName)) {
            return;
        }
        var id = $('.userRoleSet').attr('_id');
        $.getJSON('system/user.action?_act=update', {
            'update.id': id,
            'update.name': 'ROLE_ID',
            'update.value': value
        }, function (rs) {
            if (rs.code == code.SUCCESS || rs.code == code.FINISH) {
                $('.userRole').text(roleName);
                $('.userRoleSetTree').parent().dialog('close');
            }
            alert(msg[rs.code]);
        });
    }
</script>